package com.jrx.anytxn.investor.mapper.ext;

import com.jrx.anytxn.investor.entity.AmLoanAccountInvestorInfo;
import com.jrx.anytxn.investor.mapper.base.AmLoanAccountInvestorInfoMapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * 订单账户mapper扩展
 *
 * @author liuyang
 * @date 2020-05-22
 **/
public interface ExtAmLoanAccountInvestorInfoMapper extends AmLoanAccountInvestorInfoMapper {

    /**
     * 批量插入出资方订单账户信息
     *
     * @param loanAccountInvestorInfos 订单账户信息
     * @return int 保存的条数
     * @author liuyang
     * @date 2020-05-22
     */
    int batchInsertLoanAccount(List<AmLoanAccountInvestorInfo> loanAccountInvestorInfos);

    /**
     * 根据下次还款日、状态查询订单账户  抛账批次使用
     *
     * @param nextPaymentDate 下一次还款日
     * @param statusList      贷款状态
     * @return List<AmLoanAccountInvestorInfo> 订单账户
     * @author liuyang
     * @date 2020-05-25
     */
    List<AmLoanAccountInvestorInfo> selectByNextPaymentDateAndAccountStatusForBatch(@Param("nextPaymentDate") Date nextPaymentDate, @Param("statusList") List statusList);

    /**
     * 批量更新订单账户信息（批量可用）
     *
     * @param amLoanAccountInfoList 订单账户
     * @return int 更新的条数
     * @author liuyang
     * @date 2020-05-25
     */
    int batchUpdateLoanAccountForBatch(List<AmLoanAccountInvestorInfo> amLoanAccountInfoList);

    /**
     * 根据对客订单获取所以联合贷订单
     *
     * @param loanId
     * @param customerId
     * @param tenantId
     * @return
     */
    List<AmLoanAccountInvestorInfo> findInvestorLoan(String loanId, String customerId, String tenantId);


    /**
     * 根据出资方贷款订单ID获取贷款账户信息表
     *
     * @param investorLoanId 出资方贷款id
     * @param customerId     客户id
     * @param tenantId       租户id
     * @return AmLoanAccountInvestorInfo 订单账户信息
     * @author liuyang
     * @date 2020-05-26
     */
    AmLoanAccountInvestorInfo selectByInvestorLoanIdAndCustId(@Param("investorLoanId") String investorLoanId, @Param("customerId") String customerId,
                                                              @Param("tenantId") String tenantId);

    /**
     * 批量更新（作用于联机）
     *
     * @param updateLoanList
     */
    void batchUpdate(List<AmLoanAccountInvestorInfo> updateLoanList);

    /**
     * 根据出资方贷款id和状态查询订单账户
     *
     * @param investorLoanId 出资方贷款id
     * @param customerId     客户id
     * @param tenantId       租户id
     * @param statusList     状态
     * @return AmLoanAccountInvestorInfo 订单账户信息
     * @author liuyang
     * @date 2020-05-27
     */
    AmLoanAccountInvestorInfo selectByInvestorLoanIdAndAccountStatus(@Param("investorLoanId") String investorLoanId,
                                                                     @Param("customerId") String customerId,
                                                                     @Param("tenantId") String tenantId,
                                                                     @Param("statusList") List statusList);

    /**
     * 根据状态查询订单账户
     *
     * @param accountStatus 账户状态
     * @return List<AmLoanAccountInvestorInfo> 订单账户
     * @author liuyang
     * @date 2020-05-28
     */
    List<AmLoanAccountInvestorInfo> selectByAccountStatusForBatch(@Param("accountStatus") String accountStatus);

    /**
     * 根据状态查询订单账户
     *
     * @param statusList 账户状态
     * @return List<AmLoanAccountInvestorInfo> 订单账户
     * @author liuyang
     * @date 2020-05-29
     */
    List<AmLoanAccountInvestorInfo> selectForUpdateUncastIntr(@Param("statusList") List<String> statusList);

    List<AmLoanAccountInvestorInfo> selectByStatusList(@Param("statusList") List<String> statusList);

    List<AmLoanAccountInvestorInfo> selectPayOffDateAndStatus(@Param("statusList") List<String> statusList, @Param("payoffDate") String payoffDate);


    /**
     * 根据以下信息查询资金方贷款账户信息
     *
     * @param tenantId   租户ID
     * @param customerId 客户ID
     * @param loanId     贷款订单ID
     * @param investorId 资金方ID
     * @return java.util.List<com.jrx.anytxn.investor.entity.AmLoanAccountInvestorInfo>
     * @author fan.yang
     * date: 2020/6/23 0023 下午 15:48
     */
    List<AmLoanAccountInvestorInfo> selectAccountByTenIdAndCusIdAndLoanIdAndInveId(@Param("tenantId") String tenantId, @Param("customerId") String customerId, @Param("loanId") String loanId, @Param("investorId") String investorId);

    /**
     * 根据对客订单获取所以联合贷订单
     *
     * @param customerId
     * @param tenantId
     * @return
     */
    List<AmLoanAccountInvestorInfo> findByCust(String customerId, String tenantId, List<String> statusList);

}